package log

import "strings"

const (
	LOG_LEVEL_DEBUG = 0xFF
	LOG_LEVEL_ERROR = 0x01
	LOG_LEVEL_WARN  = 0x02 | LOG_LEVEL_ERROR
	LOG_LEVEL_INFO  = 0x04 | LOG_LEVEL_WARN
)

var logLevelMap map[int]string = map[int]string{
	LOG_LEVEL_DEBUG: "DEBUG",
	LOG_LEVEL_ERROR: "ERROR",
	LOG_LEVEL_WARN:  "WARN",
	LOG_LEVEL_INFO:  "INFO",
}

func FindLevel(name string) int {
	name = strings.ToUpper(strings.TrimSpace(name))
	for l, n := range logLevelMap {
		if name == n {
			return l
		}
	}
	return LOG_LEVEL_INFO
}

func LevelName(level int) string {
	return logLevelMap[level]
}

// Logger 接口
type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}
